package com.m.sms.service;


import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.m.sms.response.SmsSendResponseBody;
import com.m.sms.exception.ValidateParamsException;
import com.m.sms.params.SmsSendRequestBody;

/**
 * Description
 *
 * @Auther [li.wang@jsxfedu.com]
 * @Date 2025/3/20 09:51
 * @Version 1.0
 * @Copyright (c) 2022 京师讯飞
 */
public interface ISmsService {

    /**
     * 发送短信
     * @param smsSendRequestBody
     * @return
     * @throws Exception
     */
    SmsSendResponseBody sendSms(SmsSendRequestBody smsSendRequestBody);

    /**
     * 校验参数
     * @param smsSendRequestBody
     */
    default void validateParams(SmsSendRequestBody smsSendRequestBody) {
        if (StrUtil.isEmpty(smsSendRequestBody.getTelId())) {
            throw new ValidateParamsException("短信模板ID不能为空");
        }
        if (StrUtil.isEmpty(smsSendRequestBody.getMobile()) && CollectionUtil.isEmpty(smsSendRequestBody.getMobileList())) {
            throw new ValidateParamsException("mobile和mobileList不能同时为空");
        }

        if (StrUtil.isNotEmpty(smsSendRequestBody.getMobile()) && CollectionUtil.isNotEmpty(smsSendRequestBody.getMobileList())) {
            throw new ValidateParamsException("mobile和mobileList不能同时存在");
        }

    }
}
